package com.hsjk.szwj.module.official.service.unit.impl;

import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleBannerCreateReqVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleBannerDetailRespVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleBannerPageReqVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleBannerPageRespVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleBannerUpdateReqVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleDiyCreateReqVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleDiyDetailRespVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleDiyPageReqVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleDiyPageRespVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleDiyUpdateReqVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleFeedCreateReqVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleFeedDetailRespVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleFeedPageReqVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleFeedPageRespVO;
import com.hsjk.szwj.module.official.controller.admin.unit.vo.AdminModuleFeedUpdateReqVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleBannerDetailRespVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleBannerPageReqVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleBannerPageRespVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleDiyDetailRespVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleDiyPageReqVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleDiyPageRespVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleFeedDetailRespVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleFeedPageReqVO;
import com.hsjk.szwj.module.official.controller.app.unit.vo.AppModuleFeedPageRespVO;
import com.hsjk.szwj.module.official.conver.unit.UnitConvert;
import com.hsjk.szwj.module.official.dal.dataobject.unit.OfficialWebsiteModuleBannerDO;
import com.hsjk.szwj.module.official.dal.dataobject.unit.OfficialWebsiteModuleDiyDO;
import com.hsjk.szwj.module.official.dal.dataobject.unit.OfficialWebsiteModuleFeedDO;
import com.hsjk.szwj.module.official.dal.mysql.unit.IOfficialWebsiteModuleBannerMapper;
import com.hsjk.szwj.module.official.dal.mysql.unit.IOfficialWebsiteModuleDiyMapper;
import com.hsjk.szwj.module.official.dal.mysql.unit.IOfficialWebsiteModuleFeedMapper;
import com.hsjk.szwj.module.official.service.unit.IUnitService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/11/23 22:40
 **/
@Service
public class UnitServiceImpl implements IUnitService {
    @Resource
    private IOfficialWebsiteModuleBannerMapper bannerMapper;

    @Resource
    private IOfficialWebsiteModuleDiyMapper diyMapper;

    @Resource
    private IOfficialWebsiteModuleFeedMapper feedMapper;

    @Override
    public Boolean createModuleBanner(AdminModuleBannerCreateReqVO reqVO) {
        OfficialWebsiteModuleBannerDO officialWebsiteModuleBannerDO = UnitConvert.INSTANCE.convertModuleBannerDO(reqVO);
        int insert = bannerMapper.insert(officialWebsiteModuleBannerDO);
        return insert > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public AdminModuleBannerDetailRespVO getAdminModuleBannerDetail(Long id) {
        OfficialWebsiteModuleBannerDO officialWebsiteModuleBannerDO = bannerMapper.selectById(id);
        return UnitConvert.INSTANCE.convertAdminModuleBannerDetailRespVO(officialWebsiteModuleBannerDO);
    }

    @Override
    public AppModuleBannerDetailRespVO getAppModuleBannerDetail(Long id) {
        OfficialWebsiteModuleBannerDO officialWebsiteModuleBannerDO = bannerMapper.selectById(id);
        return UnitConvert.INSTANCE.convertAppModuleBannerDetailRespVO(officialWebsiteModuleBannerDO);
    }

    @Override
    public Boolean updateModuleBanner(AdminModuleBannerUpdateReqVO reqVO) {
        OfficialWebsiteModuleBannerDO officialWebsiteModuleBannerDO = UnitConvert.INSTANCE.convertModuleBannerDO(reqVO);
        int update = bannerMapper.updateById(officialWebsiteModuleBannerDO);
        return update > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public Boolean deleteModuleBanner(Long id) {
        int result = bannerMapper.deleteById(id);
        return result > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public PageResult<AdminModuleBannerPageRespVO> getAdminModuleBannerPage(AdminModuleBannerPageReqVO reqVO) {
        PageResult<OfficialWebsiteModuleBannerDO> courseLiveDOPageResult = bannerMapper.selectAdminPage(reqVO);
        return UnitConvert.INSTANCE.convertAdminModuleBannerPageRespVO(courseLiveDOPageResult);
    }

    @Override
    public PageResult<AppModuleBannerPageRespVO> getAppModuleBannerPage(AppModuleBannerPageReqVO reqVO) {
        PageResult<OfficialWebsiteModuleBannerDO> courseLiveDOPageResult = bannerMapper.selectAppPage(reqVO);
        return UnitConvert.INSTANCE.convertAppModuleBannerPageRespVO(courseLiveDOPageResult);

    }


    @Override
    public Boolean createModuleDiy(AdminModuleDiyCreateReqVO reqVO) {
        OfficialWebsiteModuleDiyDO officialWebsiteModuleDiyDO = UnitConvert.INSTANCE.convertModuleDiyDO(reqVO);
        int insert = diyMapper.insert(officialWebsiteModuleDiyDO);
        return insert > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public AdminModuleDiyDetailRespVO getAdminModuleDiyDetail(Long id) {
        OfficialWebsiteModuleDiyDO officialWebsiteModuleDiyDO = diyMapper.selectById(id);
        return UnitConvert.INSTANCE.convertAdminModuleDiyDetailRespVO(officialWebsiteModuleDiyDO);
    }

    @Override
    public AppModuleDiyDetailRespVO getAppModuleDiyDetail(Long id) {
        OfficialWebsiteModuleDiyDO officialWebsiteModuleDiyDO = diyMapper.selectById(id);
        return UnitConvert.INSTANCE.convertAppModuleDiyDetailRespVO(officialWebsiteModuleDiyDO);
    }

    @Override
    public Boolean updateModuleDiy(AdminModuleDiyUpdateReqVO reqVO) {
        OfficialWebsiteModuleDiyDO officialWebsiteModuleDiyDO = UnitConvert.INSTANCE.convertModuleDiyDO(reqVO);
        int update = diyMapper.updateById(officialWebsiteModuleDiyDO);
        return update > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public Boolean deleteModuleDiy(Long id) {
        int result = diyMapper.deleteById(id);
        return result > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public PageResult<AdminModuleDiyPageRespVO> getAdminModuleDiyPage(AdminModuleDiyPageReqVO reqVO) {
        PageResult<OfficialWebsiteModuleDiyDO> officialWebsiteModuleDiyDOPageResult = diyMapper.selectAdminPage(reqVO);
        return UnitConvert.INSTANCE.convertAdminModuleDiyPageRespVO(officialWebsiteModuleDiyDOPageResult);
    }

    @Override
    public PageResult<AppModuleDiyPageRespVO> getAppModuleDiyPage(AppModuleDiyPageReqVO reqVO) {
        PageResult<OfficialWebsiteModuleDiyDO> officialWebsiteModuleDiyDOPageResult = diyMapper.selectAppPage(reqVO);
        return UnitConvert.INSTANCE.convertAppModuleDiyPageRespVO(officialWebsiteModuleDiyDOPageResult);

    }

    @Override
    public Boolean createModuleFeed(AdminModuleFeedCreateReqVO reqVO) {
        OfficialWebsiteModuleFeedDO officialWebsiteModuleFeedDO = UnitConvert.INSTANCE.convertModuleFeedDO(reqVO);
        int insert = feedMapper.insert(officialWebsiteModuleFeedDO);
        return insert > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public AdminModuleFeedDetailRespVO getAdminModuleFeedDetail(Long id) {
        OfficialWebsiteModuleFeedDO officialWebsiteModuleFeedDO = feedMapper.selectById(id);
        return UnitConvert.INSTANCE.convertAdminModuleFeedDetailRespVO(officialWebsiteModuleFeedDO);
    }

    @Override
    public AppModuleFeedDetailRespVO getAppModuleFeedDetail(Long id) {
        OfficialWebsiteModuleFeedDO officialWebsiteModuleFeedDO = feedMapper.selectById(id);
        return UnitConvert.INSTANCE.convertAppModuleFeedDetailRespVO(officialWebsiteModuleFeedDO);

    }

    @Override
    public Boolean updateModuleFeed(AdminModuleFeedUpdateReqVO reqVO) {
        OfficialWebsiteModuleFeedDO officialWebsiteModuleFeedDO = UnitConvert.INSTANCE.convertModuleFeedDO(reqVO);
        int update = feedMapper.updateById(officialWebsiteModuleFeedDO);
        return update > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public Boolean deleteModuleFeed(Long id) {
        int result = feedMapper.deleteById(id);
        return result > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    @Override
    public PageResult<AdminModuleFeedPageRespVO> getAdminModuleFeedPage(AdminModuleFeedPageReqVO reqVO) {
        PageResult<OfficialWebsiteModuleFeedDO> officialWebsiteModuleFeedDOPageResult = feedMapper.selectAdminPage(reqVO);
        return UnitConvert.INSTANCE.convertAdminModuleFeedPageRespVO(officialWebsiteModuleFeedDOPageResult);
    }

    @Override
    public PageResult<AppModuleFeedPageRespVO> getAppModuleFeedPage(AppModuleFeedPageReqVO reqVO) {
        PageResult<OfficialWebsiteModuleFeedDO> officialWebsiteModuleFeedDOPageResult = feedMapper.selectAppPage(reqVO);
        return UnitConvert.INSTANCE.convertAppModuleFeedPageRespVO(officialWebsiteModuleFeedDOPageResult);
    }
}
